package com.tanhua.manage.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tanhua.manage.domain.Log;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

public interface LogMapper extends BaseMapper<Log> {
    @Select("SELECT COUNT(*) FROM tb_log WHERE log_time=#{now} AND TYPE=#{type}")
    long queryNumsByType(@Param("now") String now,@Param("type") String type);

    //查询活跃人数
    @Select("SELECT COUNT(DISTINCT user_id) FROM tb_log WHERE log_time=#{now}")
    long queryNumsByDate(String now);

    @Select("SELECT COUNT(DISTINCT user_id) FROM tb_log WHERE log_time=#{now} AND user_id IN (\n" +
            "\n" +
            "SELECT user_id FROM tb_log WHERE log_time=#{yesterday} AND TYPE='0102')\n")
    long queryRetention1d(@Param("now") String now,@Param("yesterday") String yesterday);
}
